package org.jordens.jdbcspy.jmx;

import java.util.*;

/**
 * MBean exposing various query statistics tracked by the JDBCSpy driver.
 *
 * @author Adam Jordens
 */
public interface JDBCSpyMBean
{
    public static final String NAME = "org.jordens.jdbcspy.jmx:type=JDBCSpyMBean";

    /**
     * @return All QueryStatistics since the last reset 
     */
    public Collection<QueryStatistic> listQueryStatistics();

    /**
     * @return # of queries executed since the last reset
     */
    public Long getNumberOfQueriesExecuted();

    /**
     * @return Amount of time (ms) spent executing SQL queries since the last reset
     */
    public Long getSQLExecutionTime();
    
    /**
     * @return # of milliseconds between automatic resets, -1 if automatic resets are disabled
     */
    public long getResetInterval();

    /**
     * @param ms # of milliseconds between automatic resets
     */
    public void setResetInterval(long ms);

    /**
     * Clear all tracked information.
     */
    public void reset();

    /**
     * Enable statistics gathering, will do nothing if already enabled.
     */
    public void enable();

    /**
     * Disable statistics gathering, will do nothing if already disabled.
     */
    public void disable();

    /**
     * Explicitly insert a marking message into the log
     *
     * @param message Message to log
     * @return whether or not the message was logged (will return false if logging is disabled)
     */
    public boolean mark(String message);
}
